package com.mymvc.from;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {

	public FullForm()
	{
		
	}
	
	public static ActionForm full(String formpath, HttpServletRequest request){
		ActionForm actionForm = null;
		try {
			Class clazz = Class.forName(formpath);
			actionForm = (ActionForm) clazz.newInstance();
			Field[] field = clazz.getDeclaredFields();
			for(Field f:field) {
				f.setAccessible(true);
				f.set(actionForm, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return actionForm;
	}
}
